"""Lead AI summary Pydantic schemas."""

from __future__ import annotations

from typing import Any

from pydantic import Field

from ..models.lead_ai_summary import AIProvider
from ..schemas.base import ORMBase, TimestampModel


class LeadAISummaryBase(ORMBase):
    """Base LeadAISummary schema."""

    provider: AIProvider = AIProvider.QWEN3
    keywords: list[str] | None = None
    pain_points: list[str] | None = None
    suggested_actions: list[str] | None = None
    contacts_highlight: dict[str, Any] | None = None
    reviewed: bool = False


class LeadAISummaryCreate(LeadAISummaryBase):
    """Schema for creating a lead AI summary."""

    lead_id: int
    raw_prompt: str = Field(..., min_length=1)
    raw_response: str = Field(..., min_length=1)


class LeadAISummaryUpdate(ORMBase):
    """Schema for updating a lead AI summary."""

    keywords: list[str] | None = None
    pain_points: list[str] | None = None
    suggested_actions: list[str] | None = None
    contacts_highlight: dict[str, Any] | None = None
    reviewed: bool | None = None
    reviewer_id: int | None = None


class LeadAISummaryOut(LeadAISummaryBase, TimestampModel):
    """Schema for lead AI summary output."""

    id: int
    lead_id: int
    reviewer_id: int | None = None

    # Audit fields (optional in output for security)
    raw_prompt: str | None = None  # Only for admin/debug
    raw_response: str | None = None  # Only for admin/debug
